<template>
    <div class="search-songs">
        <album-content :songList="listOfSongs"/>
    </div>
</template>

<script>
import AlbumContent from "@/components/AlbumContent";
import {mapGetters} from 'vuex';
import {mixin} from "../../mixins/index";
//import {likeSongOfName} from "@/api";

export default {
    name: "SearchSongs",
    mixin: [mixin],
    components: {AlbumContent},
    //计算，监听listOfSongs的set变化
    computed:{
        ...mapGetters([
            'listOfSongs'
        ])
    },
    //页面加载完
    mounted(){
        mixin.methods.getSong(this.$route.query.keywords);
        // if (!this.$route.query.keywords) {
        //     this.$store.commit('setListOfSongs', [])
        //     return
        // }
        // likeSongOfName(this.$route.query.keywords)
        //     .then(res => {
        //         //console.log(res[0].name);
        //         if (!res.length) {
        //             this.$store.commit('setListOfSongs', [])
        //             mixin.methods.notify('系统暂无该歌曲', 'warning')
        //         } else {
        //             this.$store.commit('setListOfSongs', res)
        //         }
        //     })
        //     .catch(err => {
        //         console.log(err)
        //     })
    }
}
</script>

<style lang="scss" scoped>
@import "../../assets/css/search-songs";
</style>